;(function($){
	$.fn.spa_basic_info = function(opts){
		var el = this;
		var opt = {
			no : "",
			dataBack : function(){},
			closeBack : function(){},
		}
		var param = $.extend(opt,opts);
		var app = new App(el,param);
	}
	
	var App = function(el,param){
		this.el = el;
		this.param = param;
		var t = this;
		t.init();
	}
	
	App.prototype = {
		bindEvent : function(){
			var el = this.el;
			var param = this.param;
			var t = this;
			
		},
		init : function(){
			var el = this.el;
			var param = this.param;
			var t = this;
			var html = t.initHtml(param.valuejson);
			$("#"+param.parentId).html(html);
			var basicDs = {};
			if(param.type=="modal"){
				hide = "";
				basicDs = param.ct_brzd[0];
			}else{
				basicDs = t.getDs();
			}
			
			var str = "";
			var basic_color = "";
			el.find(".rsv").hide();
			if(!basicDs.status_c){
				str='<span style="color:'+basic_color+';margin-left:5px;">'+$.i18n.propJsp("未选手牌")+'<span>';
			}else if(basicDs.status_c=="未结"){
				str='<i class="ace-icon fa fa-linkedin bigger-300" style="color:#6fb3e0;"></i>';
				basic_color = "#6fb3e0"
				str+= '<br/><span style="color:'+basic_color+';margin-left:5px;">'+basicDs.status_c+'<span>';
			}else if(basicDs.status_c=="预定"){
				el.find(".comm_div").hide();
        		el.find(".rsv").show();
				str='<i class="ace-icon fa fa-registered bigger-300" style="color:green;"></i>';
				basic_color = "green"
				str+= '<br/><span style="color:'+basic_color+';margin-left:5px;">'+basicDs.status_c+'<span>';
			}else if(basicDs.status_c=="取消"){
				str='<i class="ace-icon fa fa-user-times bigger-300" style="color:#333333;"></i>';
				basic_color = "#333333"
				str+= '<br/><span style="color:'+basic_color+';margin-left:5px;">'+basicDs.status_c+'<span>';
			}else if(basicDs.status_c=="已结账"){
				str='<i class="ace-icon fa fa-circle-o bigger-300" style="color:red;"></i>';
				basic_color = "red"
				str+= '<br/><span style="color:'+basic_color+';margin-left:5px;">'+basicDs.status_c+'<span>';
			}else{
				str='<span style="color:'+basic_color+';margin-left:5px;">'+(basicDs.status_c||"")+'<span>';
			}
			$("#"+param.parentId).find("span").each(function(k,v){
				var value = $.trim((basicDs[v.id]||""));
				$(v).html(value)
			})
			
			var content = ''
			if(basicDs["content"]){
				if(JSON.parse(basicDs["content"]).length>0){
					$("#contentBox").removeClass("hide")
					$.each(JSON.parse(basicDs["content"]),function(kk,vv){
						content+='<span style="font-weight:bold">'+$.i18n.propJsp(vv.name)+':</span>'+'<span style="font-size:15px;">'+$.i18n.propJsp(vv.value)+'；</span>'
					})
				}
			}
			$("#"+param.parentId).find("div[id='content']").append(content);
			$("#"+param.parentId).find("div[id='status_c']").html(str);
			$("#"+param.parentId).find(".profile-info-name").css("color","black").css("font-size","14px");
			$("#"+param.parentId).find("span[class='basic_color']").css("color",basic_color).css("font-size","15px");
			t.bindEvent();	
		},
		initHtml : function(){
			var el = this.el;
			var param = this.param;
			var t = this;
			
			var hide = "hide";
			if(param.type=="modal"){
				hide = "";
			}
			var positionHtml = "";
			if(param.position=="jsp"){//jsp页面显示
				positionHtml = 	'<div id="" class="col-xs-4 no-padding hide" >'+ 
									'<div style="width:69px;" id="label_date_c" class="profile-info-name">'+$.i18n.propJsp("佣金")+'</div>'+
									'<div class="profile-info-value">'+
										'<span class="basic_color" id="comm"></span>'+//class="editable editable-click" data-type="text"
									'</div>'+
								'</div>'+
								'<div id="" class="col-xs-8 no-padding" >'+
									'<div id="label_date_c" class="profile-info-name" style="width:69px !important;">'+$.i18n.propJsp("备注")+'</div>'+
									'<div class="profile-info-value">'+
										'<span class="basic_color" id="bz" style="width:320px;display:block;overflow:hidden;white-space:nowrap;text-overflow: ellipsis;"></span>'+//class="editable editable-click" data-type="text"
									'</div>'+
								'</div>';
			}else{
				positionHtml = '<div id="" class="col-xs-4 no-padding" >'+
									'<div style="width:69px;" id="label_th" class="profile-info-name">'+$.i18n.propJsp("公司")+'</div>'+
									'<div class="profile-info-value">'+
										'<span class="basic_color"  id="company"></span>'+
										'<i id="help_company" class="help-button btn-info" style="float:right;">?</i>'+
									'</div>'+
								'</div>'+
								'<div id="" class="col-xs-3 no-padding" >'+
									'<div style="width:69px;" id="label_rs" class="profile-info-name">'+$.i18n.propJsp("营销员")+'</div>'+
									'<div class="profile-info-value">'+
										'<span class="basic_color" id="linkman"></span>'+
										'<i id="help_linkman" class="help-button btn-info" style="float:right;">?</i>'+
									'</div>'+
								'</div>'+
								'<div id="" class="col-xs-5 no-padding" >'+
									'<div style="width:69px;" id="label_date_c" class="profile-info-name">'+$.i18n.propJsp("备注")+'</div>'+
									'<div class="profile-info-value">'+
										'<span class="basic_color" id="bz" style="max-width:290px;display:block;overflow:hidden;white-space:nowrap;text-overflow: ellipsis;"></span>'+
									'</div>'+
								'</div>';
			}
			var html = 	'<div class="profile-user-info no-margin" style="width:100%">'+// profile-user-info-striped
							'<div class="profile-info-row">'+
							'<div id="status_c" class="col-xs-1" style="padding-top:13px;padding-bottom:20px;"></div>'+
							'<div class="col-xs-11 no-padding">'+
								'<div class="col-xs-12 no-padding">'+
									'<div id="" class="col-xs-4 no-padding" >'+
										'<div style="width:69px;" id="label_th" class="profile-info-name">'+$.i18n.propJsp("台号")+'</div>'+
										'<div class="profile-info-value">'+
											'<span class="basic_color"  id="th"></span>'+
											'<span class="basic_color"  id="mc"></span>'+
											'<span class="basic_color"  id="cwlx_c"></span>'+
										'</div>'+
									'</div>'+
									'<div id="" class="col-xs-3 no-padding" >'+
										'<div style="width:69px;" id="label_rs" class="profile-info-name">'+$.i18n.propJsp("人数")+'</div>'+
										'<div class="profile-info-value">'+
											'<span class="basic_color" id="rs"></span>'+
										'</div>'+
									'</div>'+
									'<div id="" class="col-xs-5 no-padding" >'+
										'<div style="width:69px;" id="label_date_c" class="profile-info-name">'+$.i18n.propJsp("NO")+'</div>'+
										'<div class="profile-info-value">'+
											'<span class="basic_color" id="no"></span>'+
											'<span class="basic_color" id="ktrq_c"></span>'+
										'</div>'+
									'</div>'+
								'</div>'+
								'<div class="col-xs-12 no-padding">'+
									'<div id="" class="col-xs-4 no-padding" >'+
										'<div style="width:69px;" id="label_date_c" class="profile-info-name">'+$.i18n.propJsp("日期")+'</div>'+
										'<div class="profile-info-value">'+
											'<span class="basic_color" id="ktrq"></span>'+
											'<span class="basic_color" id="dep_t"></span>'+
										'</div>'+
									'</div>'+
									'<div id="" class="col-xs-3 no-padding">'+
										'<div style="width:69px;" id="label_xfje" class="profile-info-name">'+$.i18n.propJsp("消费")+'</div>'+
										'<div class="profile-info-value">'+
											'<span class="basic_color" id="xfje"></span>'+
										'</div>'+
									'</div>'+
									'<div id="" class="col-xs-5 no-padding">'+
										'<div style="width:69px;" id="label_syy" class="profile-info-name">'+$.i18n.propJsp("收银")+'</div>'+
										'<div class="profile-info-value">'+
											'<span class="basic_color" id="syy"></span>'+
										'</div>'+
									'</div>'+
								'</div>'+
								'<div class="col-xs-12 no-padding">'+
									'<div id="" class="col-xs-4 no-padding rsv" >'+
										'<div style="width:69px;" id="label_th" class="profile-info-name">'+$.i18n.propJsp("姓名")+'</div>'+
										'<div class="profile-info-value">'+
											'<span class="basic_color"  id="gname"></span>'+
										'</div>'+
									'</div>'+
									'<div id="" class="col-xs-3 no-padding rsv" >'+
										'<div style="width:69px;" id="label_rs" class="profile-info-name">'+$.i18n.propJsp("电话")+'</div>'+
										'<div class="profile-info-value">'+
											'<span class="basic_color" id="tel"></span>'+
											'<i class="help-button btn-info" data-modal="ho_arcust" style="float:right;">?</i>'+
										'</div>'+
									'</div>'+
									'<div id="" class="col-xs-5 no-padding rsv" >'+
										'<div style="width:69px;" id="label_date_c" class="profile-info-name">'+$.i18n.propJsp("备注")+'</div>'+
										'<div class="profile-info-value">'+
											'<span class="basic_color" id="bz" style="width:290px;display:block;overflow:hidden;white-space:nowrap;text-overflow: ellipsis;"></span>'+
										'</div>'+
									'</div>'+
								'</div>'+
								'<div class="col-xs-12 no-padding comm_div">'+
									positionHtml+
								'</div>'+
							'</div>'+
							'<div id="contentBox" class="col-xs-12 no-padding hide" >'+
								'<div class="alert alert-block alert-warning" style="padding:5px;">'+
									'<button type="button" class="close" data-dismiss="alert">'+
										'<i class="ace-icon fa fa-times"></i>'+
									'</button>'+
									'<div id="content"></div>'+
								'</div>'+
							'</div>'+
						'</div>'+
					'</div>';
			return html;
		},
		getDs : function(){
			var el = this.el;
			var param = this.param;
			var t = this;
			
			var json_zd = {}
			var str={"arg":{"no":param.no,th:param.th}};
			
			jQuery.ajax({
				type : 'POST',
				async:false, 
				url :  $.HSAPI_AJAXURL+"/qms/mobile/procedure2",
				data : $.HSAPI_ASKJSONINFO( JSON.stringify(str),'POSOrderRetrieveDetailBy','{}'),
				dataType : 'json',  
				success : function(data){
		            if(data.RETURN == 1){
		            	json_zd = data.ct_brzd[0]
		            	param.dataBack((json_zd||{}));
		            }else{
		            	if(data.hasOwnProperty("gritter")){
							if(data.hasOwnProperty("gritterstyle"))
								jf_successDelayed(data.gritter,2000,data.gritterstyle);
							else
								jf_successDelayed(data.gritter,2000); 
						}else{
		    				jf_alert(data.MSG)
						}
					}
				},  
				error : function(data){  
					systoast('POSOrderRetrieveDetailBy:','系统后台提交错!' + JSON.stringify(data),'error')
				}  
			});
			return json_zd
		},
	}
	
})(jQuery);